<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>查询并显示数据</title>
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/font-awesome.css">
<link rel="stylesheet" href="./css/font-awesome.min.css">
</head>
    <body>
        <div class="container">
            <div class="row">
                <div class="col-lg-12 mx-auto">
                    <div class="my-3">
                        <h3 class="pull-left">用户列表</h3>
                            <a href="./insert.html" class="btn btn-success pull-right">
                            <i class="fa fa-address-card" aria-hidden="true"></i> 添加新用户</a>
                        </div>
                    <table class='table table-bordered table-striped'>
                        <thead class="thead-dark">
                        <tr>
                            <th>序号</th>
                            <th>id</th>
                            <th>姓名</th>
                            <th>邮箱</th>
                            <th>电话号码</td>
                            <th>操作</th>
                        </tr>
                        </thead>
                    <?php
                    // 引入链接文件
                     require_once "conn.php";
                    //  返回结果记录集
                     $result = mysqli_query($link,"select * from users");
                    //  $row= mysqli_fetch_array($result);
                    
                    if (mysqli_num_rows($result)>0) {
                    $i=1;             
                    while($row = mysqli_fetch_array($result)) {
                    ?>
                        <tr>
                            <td class="text-center"><?php  $i; ?></td>
                            <td class="text-center"><?php echo $row["id"]; ?></td>
                            <td class="text-center"><?php echo $row["name"]; ?></td>
                            <td><?php echo $row["email"]; ?></td>
                            <td><?php echo $row["mobile"]; ?></td>
                            <td class="text-center">
                                <a class="btn btn-success" href="update.php?id=<?php echo $row["id"]; ?>" class="btn btn-primary btn-sm" ><i class="fa fa-pencil fafw"></i> 修改</a>
                                <a href="delete.php?id=<?php echo $row["id"]; ?>"class="btn btn-warning btn-sm"><i class="fa fa-trash-o fa-fw"></i> 删除</a>
                            </td>
                        </tr>
                    <?php
                        $i++;}
                        }else{
                            echo "<tr><td colspan='6' class='text-center'>无数据</td></tr>";
                        }
                    ?>
                     </table>
                </div>
            </div>
        </div>
    </body>
</html>